#include <dlib/image_processing/frontal_face_detector.h>
#include <dlib/image_io.h>
#include <dlib/opencv.h>
#include <dlib/gui_widgets.h> // 添加显示窗口支持
using namespace std;
int main(int argc, char** argv) {
if (argc != 2) {
cerr << "使用方法: " << argv[0] << " <图片路径>" << endl;
return 1;
}
try {
dlib::array2d<dlib::rgb_pixel> img;
load_image(img, argv[1]);
dlib::frontal_face_detector detector = 
dlib::get_frontal_face_detector();
std::vector<dlib::rectangle> faces = detector(img);
cout << "检测到 " << faces.size() << " 张人脸" << endl;
dlib::image_window win;
win.set_image(img);
win.add_overlay(faces, dlib::rgb_pixel(255,0,0));
cout << "按回车键退出..." << endl;
cin.get();
} catch (exception& e) {
cout << "发生异常: " << e.what() << endl;
}
return 0;
}

